#include "lib.h"
#include "rfile.h"
#include "rentry.h"
#include "rfileformat.h"
using namespace Library;


/**
 * Deprecated (as of Casino 2.8.0).  This is the original resource
 * format developed back in the days of Pixel Technologies and used
 * from 1996-2004.
 */
struct ResourceFile::Format ResourceFile::Format::RESOURCE1 =
{
	RE_DISKIMAGEFORMAT_VERSION_A,
	RI_DISKIMAGEFORMAT_VERSION_A,
	RH_DISKIMAGEFORMAT_VERSION_A,
	false
};


/**
 * Deprecated (as of Casino 3.0.0).  This format was developed during
 * the early days of 2004 when individually paletted images were first
 * introduced; creating a need for compressible resource data.
 */
struct ResourceFile::Format ResourceFile::Format::RESOURCE2 =
{
	RE_DISKIMAGEFORMAT_VERSION_C,
	RI_DISKIMAGEFORMAT_VERSION_A,
	RH_DISKIMAGEFORMAT_VERSION_A,
	true
};


/**
 * This format was developed middle-to-late 2004 when internationalization
 * client development demanded long resource name support.
 */
struct ResourceFile::Format ResourceFile::Format::RESOURCE3 =
{
	RE_DISKIMAGEFORMAT_VERSION_D,
	RI_DISKIMAGEFORMAT_VERSION_A,
	RH_DISKIMAGEFORMAT_VERSION_A,
	true
};


/**
 * Convenient naming scheme which allows programs, like resource compiler,
 * to know/use the latest resource convention.
 */
struct ResourceFile::Format
	ResourceFile::Format::LATEST = ResourceFile::Format::RESOURCE3;


//----------------------------------------------------------------------------
//
//
bool8
ResourceFile::Format::operator==(ResourceFile::Format & rhs) const
{
	if (m_dif_entry == rhs.m_dif_entry &&
		m_dif_index == rhs.m_dif_index &&
		m_dif_header == rhs.m_dif_header)
		return true;

	return false;
};


String
ResourceFile::Format::asString() const
{
	if (this->operator==(RESOURCE1)) return String("RESOURCE1");
	if (this->operator==(RESOURCE2)) return String("RESOURCE2");
	if (this->operator==(RESOURCE3)) return String("RESOURCE3");

	return String("Unknown");
}


bool8
ResourceFile::Format::isValid() const
{
	if (this->operator==(RESOURCE1) ||
		this->operator==(RESOURCE2) ||
		this->operator==(RESOURCE3))
		return true;

	return false;
}
